<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
  PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
  <title>CGU - Cookie - cookie</title>
  <link rel="stylesheet" type="text/css" href="main.css" />
</head>

<body>

<div id="head">
  <div id="title">
    <h1>CGU</h1>&nbsp;&nbsp;<h2>Common &amp; General Use JavaScript</h2>
  </div>
</div>

<div id="foot">
  <div id="copy">
    <span>&copy; 2008 CGU</span>
  </div>
</div>

<div id="body">
  <div id="nav">
    <div class="pad">
      
      <div class="navlist">
        <h3>CGU</h3>
        <ul>
          <li><a href="index.html">Docs Home</a></li>
          <li><a href="functions.html">Functions</a></li>
        </ul>
      </div>
      
      <div class="navlist">
        <h3>Cookie</h3>
        <ul>
          <li class="active"><a href="function.cookie.html">cookie</a></li>
        </ul>
      </div>
      
      <div class="navlist">
        <h3>Utilities</h3>
        <ul>
          <li><a href="utility.Cookie.html">Cookie</a></li>
          <li><a href="utility.Crypto.html">Crypto</a></li>
          <li><a href="utility.JSON.html">JSON</a></li>
          <li><a href="utility.Query.html">Query</a></li>
          <li><a href="utility.Time.html">Time</a></li>
          <li><a href="utility.Type.html">Type</a></li>
        </ul>
      </div>
      
    </div>
  </div>
  
  <div id="docs">
    <div class="pad">
      <div id="content">
<!-- Start: Content -->
      
      <h1>Cookie</h1>
      
      <hr />
      
      <h2>cookie</h2>
      
      <blockquote>
        <p>Read, write, or expire a cookie.</p>
      </blockquote>
      
      <hr />
      
      <h3>Syntax</h3>
      
      <blockquote>
        <pre class="prettify"><code><span class="pln">CGU</span><span class="pun">.</span><span class="pln">cookie</span><span class="pun">(</span><span class="pln">key</span><span class="pun">,</span><span class="pln"> value </span><span class="pun">[,</span><span class="pln"> options</span><span class="pun">]);</span></code></pre>
        
        <blockquote>
          <p><code><b>key</b> &lt;String&gt;</code>: Name of the cookie.</p>
          <p><code><b>value</b> &lt;String&gt;</code>: Value of the cookie.</p>
          <p><code><b>options</b> &lt;Object&gt;</code>: Specify cookie options. <i>(optional)</i>
          <blockquote>
            <p><code><b>domain</b> &lt;String&gt;</code>: Domain/hostname associated with the cookie.</p>
            <p><code><b>duration</b> &lt;String&gt;</code>: Number of days the cookie should live.</p>
            <blockquote>
              <p><code>&lt;null&gt;</code>: Create a session cookie.</p>
              <p><code>(duration &lt; 0)</code>: Force a cookie to expire.</p>
            </blockquote>
            <p><code><b>expire</b> &lt;Boolean&gt;</code>: Force a cookie to expire.</p>
            <p><code><b>path</b> &lt;String&gt;</code>: Pathname associated with the cookie.</p>
            <p><code><b>secure</b> &lt;Boolean&gt;</code>: Create a secure cookie.</p>
          </blockquote>
        </blockquote>
      </blockquote>
      
      <hr />
      
      <h3>Modes</h3>
      
      <blockquote>
        <h4>Read</h4>
        <blockquote>
          <p><h5>Syntax</h5></p>
          <blockquote>
            <pre class="prettify"><code><span class="pln">CGU</span><span class="pun">.</span><span class="pln">cookie</span><span class="pun">(</span><span class="pln">key</span><span class="pun">);</span></code></pre>
          </blockquote>
          
          <p><h5>Return</h5></p>
          <blockquote>
            <p><code>&lt;String&gt;</code>: Value of the cookie.</p>
            <blockquote>
              <p><code>&lt;null&gt;</code>: Cookie wasn't found.</p>
            </blockquote>
          </blockquote>
        </blockquote>
          
        <h4>Write</h4>
        <blockquote>
          <p><h5>Syntax</h5></p>
          <blockquote>
            <pre class="prettify"><code><span class="pln">CGU</span><span class="pun">.</span><span class="pln">cookie</span><span class="pun">(</span><span class="pln">key</span><span class="pun">,</span><span class="pln"> value </span><span class="pun">[,</span><span class="pln"> options</span><span class="pun">]);</span></code></pre>
          </blockquote>
          
          <p><h5>Return</h5></p>
          <blockquote>
            <p><code>&lt;Boolean&gt;</code>: Success.</p>
          </blockquote>
        </blockquote>
        
        <h4>Expire</h4>
        <blockquote>
          <p><h5>Syntax</h5></p>
          <blockquote>
            <pre class="prettify"><code><span class="pln">CGU</span><span class="pun">.</span><span class="pln">cookie</span><span class="pun">(</span><span class="pln">key</span><span class="pun">,</span><span class="pln"> </span><span class="pun">...,</span><span class="pln"> </span><span class="pun">{</span><span class="pln">duration</span><span class="pun">:</span><span class="pln"> </span><span class="pun">-</span><span class="lit">1</span><span class="pun">});</span><span class="pln"> </span><span class="com">// duration &lt; 0</span></code></pre>
            <pre class="prettify"><code><span class="pln">CGU</span><span class="pun">.</span><span class="pln">cookie</span><span class="pun">(</span><span class="pln">key</span><span class="pun">,</span><span class="pln"> </span><span class="pun">...,</span><span class="pln"> </span><span class="pun">{</span><span class="pln">expire</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">true</span><span class="pun">});</span></code></pre>
          </blockquote>
          
          <p><h5>Return</h5></p>
          <blockquote>
            <p><code>&lt;Boolean&gt;</code>: Success.</p>
            <blockquote>
              <p><code>&lt;null&gt;</code>: Cookie wasn't found.</p>
            </blockquote>
          </blockquote>
        </blockquote>
      </blockquote>
      
      <hr />
      
      <h3>Example</h3>
      
      <blockquote>
        <pre class="prettify"><code><span class="pln">CGU</span><span class="pun">.</span><span class="pln">cookie</span><span class="pun">(</span><span class="str">'foo'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'bar'</span><span class="pun">,</span><span class="pln"> </span><span class="pun">{</span><span class="pln">duration</span><span class="pun">:</span><span class="pln"> </span><span class="lit">2</span><span class="pun">});</span><span class="pln"> &nbsp; </span><span class="com">//=&gt; true (Write)</span></code></pre>
        <pre class="prettify"><code><span class="pln">CGU</span><span class="pun">.</span><span class="pln">cookie</span><span class="pun">(</span><span class="str">' &nbsp; '</span><span class="pun">,</span><span class="pln"> </span><span class="str">'spc'</span><span class="pun">,</span><span class="pln"> </span><span class="pun">{</span><span class="pln">duration</span><span class="pun">:</span><span class="pln"> </span><span class="pun">-</span><span class="lit">1</span><span class="pun">});</span><span class="pln"> &nbsp;</span><span class="com">//=&gt; null (Write/Expire)</span></code></pre>
        <pre>&nbsp;</pre>
        <pre class="prettify"><code><span class="pln">CGU</span><span class="pun">.</span><span class="pln">cookie</span><span class="pun">(</span><span class="str">'foo'</span><span class="pun">);</span><span class="pln"> &nbsp;</span><span class="com">//=&gt; 'bar' (Read)</span></code></pre>
        <pre class="prettify"><code><span class="pln">CGU</span><span class="pun">.</span><span class="pln">cookie</span><span class="pun">(</span><span class="str">' &nbsp; '</span><span class="pun">);</span><span class="pln"> &nbsp;</span><span class="com">//=&gt; null (Read)</span></code></pre>
        <pre>&nbsp;</pre>
        <pre class="prettify"><code><span class="pln">CGU</span><span class="pun">.</span><span class="pln">cookie</span><span class="pun">(</span><span class="str">'foo'</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">null</span><span class="pun">,</span><span class="pln"> </span><span class="pun">{</span><span class="pln">expire</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">true</span><span class="pun">});</span><span class="pln"> &nbsp;</span><span class="com">//=&gt; true (Expire)</span></code></pre>
        <pre class="prettify"><code><span class="pln">CGU</span><span class="pun">.</span><span class="pln">cookie</span><span class="pun">(</span><span class="str">' &nbsp; '</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">null</span><span class="pun">,</span><span class="pln"> </span><span class="pun">{</span><span class="pln">expire</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">true</span><span class="pun">});</span><span class="pln"> &nbsp;</span><span class="com">//=&gt; null (Expire)</span></code></pre>
        <pre>&nbsp;</pre>
        <pre class="prettify"><code><span class="pln">CGU</span><span class="pun">.</span><span class="pln">cookie</span><span class="pun">(</span><span class="str">'foo'</span><span class="pun">);</span><span class="pln"> &nbsp;</span><span class="com">//=&gt; null (Read)</span></code></pre>
        <pre class="prettify"><code><span class="pln">CGU</span><span class="pun">.</span><span class="pln">cookie</span><span class="pun">(</span><span class="str">' &nbsp; '</span><span class="pun">);</span><span class="pln"> &nbsp;</span><span class="com">//=&gt; null (Read)</span></code></pre>
      </blockquote>
      
      <hr />
      
<!-- Final: Content -->
      </div>
    </div>
  </div>
</div>

  <script type="text/javascript" src="main.js"></script>
</body>

</html>
